package cn.wolfcode.crm.query.impl;

import cn.wolfcode.crm.query.QueryObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Calendar;
import java.util.Date;

@Getter
@Setter
public class CusturnQuery extends QueryObject {
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startDate;
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    private String customer;

    private String input;

    private String oldCharge;

    private String newCharge;

    public String getCustomer() {
        return empty(customer);
    }

    public String getInput() {
        return empty(input);
    }

    public String getOldCharge() {
        return empty(oldCharge);
    }

    public String getNewCharge() {
        return empty(newCharge);
    }
    public void setEndDate(Date date){
        if (date == null) {
            return;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY,23);
        calendar.set(Calendar.MINUTE,59);
        calendar.set(Calendar.SECOND,59);
        this.endDate= calendar.getTime();
    }
}
